package com.youdianda.controller;


import com.youdianda.dto.CateQueryPageDTO;
import com.youdianda.entity.YddCate;
import com.youdianda.result.Result;
import com.youdianda.service.IYddCateService;

import com.youdianda.vo.CateAllVO;
import com.youdianda.vo.CateQueryPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mosen
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_cate")
public class YddCateController {

    @Autowired
    private IYddCateService yddCateService;

    /**
     * 分类分页查询
     * @param cateQueryPageDTO
     * @return
     */
    @GetMapping("/list")
    public Result<CateQueryPageVo> CatePage(CateQueryPageDTO cateQueryPageDTO){
        return yddCateService.CatePage(cateQueryPageDTO);
    }

    /**
     * 添加分类
     * @param cate
     * @return
     */
    @PostMapping("/add")
    public Result<YddCate> addCate(@RequestBody YddCate cate){
        return yddCateService.addCate(cate);
    }

    /**
     * 根据分类id查询
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result<YddCate> CateById(String id){
        return yddCateService.CateById(id);
    }

    /**
     * 修改分类
     * @param yddCate
     * @return
     */
    @PostMapping("/update")
    public Result<YddCate> updateCate(@RequestBody YddCate yddCate){
        return yddCateService.updateCate(yddCate);
    }

    /**
     * 根据id删除分类
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result<YddCate> delCate(String id){
        return yddCateService.delCate(id);
    }

    /**
     * 查询所有分类
     * @param
     * @return
     */
    @GetMapping("/all")
    public Result<List<CateAllVO>> cateAll(){
        return yddCateService.cateAll();
    }
}
